package admin.common;

import lombok.Data;

import java.io.Serializable;

/**
 * 封装返回结果
 */
@Data
public class Result implements Serializable {
    private Integer code;
    private String message;
    private Object data;

    private Result() {
    }

    public static Result ok() {
        Result result = new Result();
        result.setCode(200);
        result.setMessage("操作成功");
        return result;
    }

    public static Result fail() {
        Result result = new Result();
        result.setCode(400);
        result.setMessage("操作失败");
        return result;
    }

    public Result data(Object data) {
        this.data = data;
        return this;
    }

    public Result message(String msg) {
        this.message = msg;
        return this;
    }

    public Result code(Integer code) {
        this.code = code;
        return this;
    }


}
